package com.xbs.controller.enterprise;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 提示
 */
import com.xbs.controller.base.BaseServlet;
import com.xbs.entity.CarModelEntity;
import com.xbs.entity.EnterpriseMotorcadeSumEntity;
import com.xbs.service.enterprise.EnterpriseIndexService;
import com.xbs.service.enterprise.EpLoginService;

@WebServlet("/enterprise/index")
public class EnterpriseIndex extends BaseServlet {
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String account = req.getParameter("account");
		String pwd = req.getParameter("pwd");
		EpLoginService service1 = new EpLoginService();
	
		if (service1.isEp(account, pwd)) {
			req.getSession().setAttribute("loginflag", "flag");
		}
		if (req.getSession().getAttribute("loginflag")!=null) {
			req.getSession().setAttribute("loginmark", true);
			String content = req.getParameter("content");
			if (content == null) {
				// 设置content的值
				req.setAttribute("content", "ls_enterprise/enterpriseIndex.jsp");
			} else {
				req.setAttribute("content", content + ".jsp");
			}
			EnterpriseIndexService service = new EnterpriseIndexService();
			List<CarModelEntity> carmodel = service.getCarmodel(account);
			req.setAttribute("cars", carmodel);
			/**
			 * 获取车队列表信息
			 */
			List<EnterpriseMotorcadeSumEntity> motorcade = service.getMotorcade();
			req.setAttribute("motorcade", motorcade);
			req.setAttribute("hha", "fjdlk");
			req.getSession().setAttribute("account", account);
			forward("businessview/ls-enterpriseindex");
		}
	else
	{
		req.setAttribute("msg1", "用户名或密码错误");
		req.setAttribute("acount", account);
		req.setAttribute("pwd", pwd);
		forward("businessview/enterpriseRent");
	}
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
}
